package com.xing.service.load;

/**
 * Created by Bradish7Y on 2017/8/21.
 */

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 读取命令行参数
 * java -jar a.jar --debug abc.txt
 */
@Component
public class CommandLineArguments {
    public static final Logger log = LoggerFactory.getLogger(CommandLineArguments.class);

    @Autowired
    public CommandLineArguments(ApplicationArguments args) {
        boolean debug = args.containsOption("debug");
        Set<String> files = args.getOptionNames();
        log.info("ApplicationArguments:{}", files);
        // if run with "--debug logfile.txt" debug=true, files=["logfile.txt"]
    }

}